// +----------------------------------------------------------------------
// | Manong.Cloud [ 领酷码农云 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://www.manong.cloud All rights reserved.
// +----------------------------------------------------------------------
// | Author: 稻草人 <qinuoyun@qq.com>
// +----------------------------------------------------------------------
// | Member: 围棋 飘逸者 Loumt Silence24
// +----------------------------------------------------------------------
const querystring = require('querystring');
const SMS_PREFIX = 'http://v.juhe.cn/sms/send?';

class Sms {

    key = '';
    tpl_id = '';

    constructor(key = '', tpl_id = '') {
        this.key = key;
        this.tpl_id = tpl_id;
    }

    async getCode(code, mobile) {
        let params = {
            mobile: mobile,
            tpl_id: this.tpl_id,
            tpl_value: `#code#=${code}`,
            key: this.key
        }

        let url = SMS_PREFIX+querystring.stringify(params);

        return await request.get(url);
    }
}

export default  Sms;
